package com.baizhi.service.impl;

import com.baizhi.dao.DrugDao;
import com.baizhi.entity.Drug;
import com.baizhi.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DrugServiceImpl implements DrugService {

    @Autowired
    private DrugDao drugDao;

    @Override
    public void insert(Drug drug) {
        drugDao.insert(drug);
    }

    @Override
    public void update(Drug drug) {
        drugDao.update(drug);
    }

    @Override
    public void delete(int[] ids) {
        drugDao.delete(ids);
    }

    @Override
    public int selectTotal(String name) {
        return drugDao.selectTotal(name);
    }

    @Override
    public List<Drug> selectDrugByPage(int page, int rows, String name) {
        if(name!=null&&"".equals(name)){
            name="%"+name+"%";
        }else {
            name=null;
        }
        int start=(page-1)*rows;
        int pageSize=rows;
        return drugDao.selectDrugByPage(start, pageSize, name);
    }
}
